1. Field of the Invention
The present invention relates generally to texture mapping in graphics systems, and more particularly to a system and method of implementing trilinear texture filtering with an optimized memory access scheme.
2. Description of Background Art
Texture mapping is a well-known technique of projecting a texture onto a surface in a graphics system. Typical applications of the technique involve reading texture data (texels) of a two-dimensional texture that represent a digitized image, and mapping the texture data onto a surface that is defined in three-dimensional space. The surface, when rendered and projected onto a two-dimensional display, is imbued with greater realism as it appears to contain the surface characteristics defined in the texture map.
In many applications, such as video games, the three-dimensional surfaces have widely varying dimensions and shapes. Some surfaces, representing objects that appear to be far away from the viewer, may be relatively small, while other surfaces, representing objects that appear to be closer, may be large. In order to allocate resources efficiently and avoid wasting valuable processor time, it is beneficial to vary the amount of detail presented for on-screen objects according to their relative apparent proximity to the viewer. Smaller, far-away objects may be rendered in less detail than larger, close-up objects, without unduly compromising the user experience.
One problem in rendering three-dimensional images is the image quality produced by applying textures to primitives such as triangles and polygons. Especially when the discrete image is generated by sampling an abstract image, visual artifacts are often included in the discrete image. Often the images need to be filtered to remove visual artifacts such as banding or aliasing effects. Additional artifacts such as banding are also caused by morphing or transforming images between various levels of detail in an image.
Multum in parvo mapping (MIP mapping) is a technique used in graphics applications to alleviate problems such as those described above and to provide varying levels of detail in texture mapping. It is based on a scheme wherein several levels of detail are made available for a particular texture map. One particular type of MIP mapping scheme is referred to as "trilinear texture filtering" because the value for a particular texel at a particular resolution level is interpolated on three values: the x-coordinate, u; the y-coordinate, v; and a linear description of the level of detail, d. Those skilled in the art will recognize that a variety of different filtering methods may be used. By using a texture map version having an appropriate level of detail for the parameters of the rendered image, MIP map schemes tend to improve the image quality by reducing the effects of the visual artifacts, and without unduly increasing the computations and resources needed.
Prior art approaches to trilinear texture filtering typically store several versions of a particular texture map, at varying levels of detail. Usually, these levels are defined by powers of two, for example, a 2.times.2 square containing four texels corresponding to one texel at the next higher level of detail is filtered (averaged) to produce the next upper level texel. In the limit, the entire texture map may be reduced to one texel at the lowest level of detail.
When a texture is being mapped, a desired level of detail is selected. As an on-screen object moves "closer to" or "farther away from" the user's point of view, this requires a change in the selected level. In other words, an object's apparent distance from the user may change from frame to frame, and where such changes cause a different stored texture map version to be used, a visible and undesirable discontinuity in resolution may occur.
Accordingly, some MIP map engines employ interpolation to provide intermediate levels of detail between stored texture map versions. In essence, such techniques gradually shift from one version to the next, so that little or no discontinuity is perceived. Conventional interpolation in MIP map engines occurs as follows. The two stored texture map versions having the closest levels of detail to the selected level are used. Four samples are read from each of the two levels. Each set of four samples is bi-linearly interpolated, resulting in two values, one for each level of detail. The bilinear interpolation is performed according to the x- and y-coordinates of the point being mapped. The two interpolated values are then interpolated according to the fractional component of the initially selected level of detail to derive a final value for the selected point. See, for example, Williams, "Pyramidal Parametrics," SIGGRAPH '83.
The above-described scheme requires that two read operations be performed to retrieve samples used in texture mapping. This is a particular problem because the processing speeds of graphic engines used to perform the mapping have increased to the point where the two read operations are the primary limitation on performance as opposed to the computation time in processing the retrieved samples. The problems with memory bandwidth and access speed are only increased because of the nature of the type of read operations being performed. The use of MIP maps requires that the samples are read from two portions of the texture map storage area, corresponding to the two levels of detail to be used in interpolation. These two areas of the texture map storage area may be, and typically are, widely separated in physical memory. The most costly type of read (in terms of performance) is one that causes a "page break", resulting in additional overhead. Since the interpolated MIP map scheme described above often fails to take advantage of memory locality, the two reads involved in retrieving the texture map versions often cause a page break, which may result in reduced speed and performance. In addition, the requirement of reading two texture map versions creates increased bandwidth requirements. Caching can be used to alleviate these problems, but only to a limited extent. Caching and other known performance-enhancing memory access techniques rely on memory locality for successive reads--two consecutive reads that are close together in physical memory may take place faster than two reads that are farther apart.
What is needed is a technique for implementing trilinear texture filtering that improves memory locality so as to reduce or eliminate page breaks and improve performance in graphics systems.